home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
64-bit_x64
/
Russian
/
cpsimage.cab
/
data
/
xps
/
XpsCoreProperties.elf
< prev
next >
Wrap
Text File
|
2009-04-23
|
4KB
|
116 lines
#load "sys/XmlWriter.elf";
#load "xps/Xps.elf";
#load "xps/XpsPackagePart.elf";
CLASS XpsCoreProperties EXTENDS XpsPackagePart {
// Fields
LIST metadata;
LIST names;
LIST propertyMap;
// Methods
METHOD setProperty (STRING name, STRING value) {
try {
this.init ();
STRING classname = this.propertyMap.ref (name: name);
LIST params = (name: name, value: value);
XpsProperty p = REFLECTION.findClass (name: classname
).newInstance (params: params
);
this.metadata.insert (name: p.name, obj: p);
if (this.names.search (name: name) == -1)
this.names.insert (obj: name, entry: this.names.length ());
}
catch {
print "Unknown property <" + name + ">";
}
}
METHOD getProperty (STRING name)
RETURNS (STRING value) {
XpsProperty prop = this.metadata.ref (name: name);
value = prop.value;
}
METHOD propertyNames ()
RETURNS (LIST names) {
names = this.names;
}
METHOD write (XmlWriter writer) {
this.init ();
writer.writeDocumentStart ();
writer.writeElementStart (localName: "coreProperties");
writer.writeAttributeString (prefix: "xmlns", localName: "dc",
text: Xps.DC_ELEMS_NAMESPACE);
writer.writeAttributeString (prefix: "xmlns", localName: "dcterms",
text: Xps.DC_TERMS_NAMESPACE);
writer.writeAttributeString (localName: "xmlns",
text: Xps.CORE_PROPS_NAMESPACE);
writer.writeAttributeString (prefix: "xmlns", localName: "xsi",
text: Xps.XSI_NAMESPACE);
XpsProperty prop;
foreach (this.names: name) {
prop = this.metadata.ref (name: name);
prop.write (writer: writer);
}
writer.writeElementEnd ();
writer.flush ();
}
METHOD init () {
if (this.propertyMap.length () != 0)
return;
this.propertyMap.insert (name: "title", obj: "XpsStringProperty");
this.propertyMap.insert (name: "subject", obj: "XpsStringProperty");
this.propertyMap.insert (name: "creator", obj: "XpsStringProperty");
this.propertyMap.insert (name: "created", obj: "XpsDateTimeProperty");
this.propertyMap.insert (name: "modified", obj: "XpsDateTimeProperty");
this.propertyMap.insert (name: "keywords", obj: "XpsGenericProperty");
}
}
/*****************************************************************************/
CLASS XpsProperty {
// Fields
STRING name;
STRING value;
// Public Methods
METHOD write (XmlWriter writer) {
}
}
CLASS XpsGenericProperty EXTENDS XpsProperty {
// Public Methods
METHOD write (XmlWriter writer) {
writer.writeElementString (localName: this.name, text: this.value);
}
}
CLASS XpsStringProperty EXTENDS XpsProperty {
// Public Methods
METHOD write (XmlWriter writer) {
writer.writeElementString (prefix: "dc", localName: this.name,
text: this.value);
}
}
CLASS XpsDateTimeProperty EXTENDS XpsProperty {
// Public Methods
METHOD write (XmlWriter writer) {
writer.writeElementStart (prefix: "dcterms", localName: this.name);
writer.writeAttributeString (prefix: "xsi", localName: "type",
text: "dcterms:W3CDTF");
writer.writeString (text: this.value);
writer.writeElementEnd ();
}
}